home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
morrison.zip
/
DIR.CB
< prev
next >
Wrap
Text File
|
1989-11-03
|
22KB
|
957 lines
/* --------------------------------------------------------------------------- */
/* */
/* DIR Macro */
/* */
/* --------------------------------------------------------------------------- */
/* */
/* This macro is designed to operate simular to the menus seen in */
/* the popular NORTON COMMANDER program. You can go UP or DOWN the */
/* tree structure on the disk by moving the cursor over the proper */
/* <DIR> entry in the directory and hitting the <Enter> key. */
/* */
/* If the <Enter> key is hit and a file (instead of a directory */
/* <DIR> entry) is highlighted then this file will be loaded into */
/* BRIEF and be ready for editing. */
/* */
/* The <Ins> or <Space> key will TOGGLE the file marker for the */
/* file that is currently highlighted. <DIR> files MAY NOT BE */
/* marked as they can not be edited. After having marked one or */
/* more (as many as you like) you can then have ALL of the MARKED */
/* files loaded into BRIEF by hitting the <Alt-L> key. */
/* */
/* If you do NOT wish to edit any files, simply hit the <Esc> key */
/* and you will be back editing the file that you started with. */
/* */
/* The <Home>, <End>, <Up>, <Down>, <PgUp>, and <PgDn> keys are */
/* used to move you around within the directory. */
/* */
/* Written BY: Robert H. Morrison, 1 July 1988 */
/* Karlsruhe, West Germany */
/* */
/* Last Update: 6 July 1988 */
/* */
/* */
#define LINE 3
#define SYSTEM 1
#define UP_DIR ".."
#define DOWN_DIR ".\\"
#define SELECT 1
#define UNSELECT 2
#define ALT_KEY 8
#include "dialog.h"
_init (...)
{
int mark_typ,
updir,
alt_done,
rows,
cols;
string new_file,
bhelp,
bdirfile,
bdirpgm,
bdiropt,
bdirtxt,
old_opt,
select,
unselect,
alt_search,
bdir;
global new_file,
bhelp,
bdirfile,
bdirpgm,
bdiropt,
bdirtxt,
old_opt,
select,
unselect,
alt_search,
alt_done,
bdir,
mark_typ,
updir,
rows,
cols;
alt_search = "\<■\| ";
alt_done = FALSE;
bhelp = lower (inq_environment ("BHELP"));
if (bhelp != "")
bhelp += "\\";
bdiropt = "F";
bdirfile = bhelp + "temp.dir";
bdirpgm = bhelp + "bmakedir.exe";
bdirtxt = bhelp + "bmakedir.txt";
bdir = bdirpgm + ((" \-" + bdiropt) + (" \>&" + bdirfile));
inq_screen_size (rows, cols);
rows -= 10;
cols -= 42;
cols /= 2;
}
dir (...)
{
extern to_bottom,
display_file_name;
int dir_buffer,
old_buffer,
dir_window,
old_window,
end_line,
line;
string temp,
this_line,
current_dir,
current_drive,
answer;
global end_line,
this_line,
line,
old_buffer,
dir_buffer,
current_dir,
current_drive,
answer;
new_file = "";
message ("Reading disk directory...");
dos (bdir);
old_buffer = inq_buffer ();
dir_buffer = create_buffer ("DIR Ver 1.00", bdirtxt, SYSTEM);
create_window (cols, rows + 4, cols + 42, 3, "Ins - + Enter F1 F2 F4 F7 F8 F9 F10 Esc");
attach_buffer (dir_buffer);
set_buffer (dir_buffer);
getwd (NULL, current_dir);
current_dir = upper (current_dir);
current_drive = substr (current_dir, 1, 1);
top_of_buffer ();
read_file (bdirfile);
up ();
inq_position (end_line, NULL);
top_of_buffer ();
keyboard_push ();
assign_to_key ("<Space>", "no_beep");
assign_to_key ("<Enter>", "select_dir");
assign_to_key ("<Home>", "top_of_dir");
assign_to_key ("<End>", "end_of_dir");
assign_to_key ("<Up>", "up_dir");
assign_to_key ("<Down>", "down_dir");
assign_to_key ("<PgUp>", "pgup_dir");
assign_to_key ("<PgDn>", "pgdown_dir");
assign_to_key ("<Ins>", "mark_dir");
assign_to_key ("<Ctrl-PgUp>", "up_1_dir");
assign_to_key ("<F1>", "help_dir");
assign_to_key ("<F2>", "change_drive");
assign_to_key ("<F4>", "load_marked");
assign_to_key ("<F7>", "make_dir");
assign_to_key ("<F8>", "delete_file");
assign_to_key ("<F9>", "set_mode");
assign_to_key ("<F10>", "_exit");
assign_to_key ("<Esc>", "_exit");
assign_to_key ("<Ctrl-\\>", "root_dir");
assign_to_key ("<\\>", "root_dir");
assign_to_key ("<Ctrl-R>", "read_dir");
assign_to_key ("<Keypad-minus>", "unselect_marks");
assign_to_key ("<Keypad-plus>", "select_marks");
assign_to_key ("<Alt-a>", "NC_alt_search a");
assign_to_key ("<Alt-b>", "NC_alt_search b");
assign_to_key ("<Alt-c>", "NC_alt_search c");
assign_to_key ("<Alt-d>", "NC_alt_search d");
assign_to_key ("<Alt-e>", "NC_alt_search e");
assign_to_key ("<Alt-f>", "NC_alt_search f");
assign_to_key ("<Alt-g>", "NC_alt_search g");
assign_to_key ("<Alt-h>", "NC_alt_search h");
assign_to_key ("<Alt-i>", "NC_alt_search i");
assign_to_key ("<Alt-j>", "NC_alt_search j");
assign_to_key ("<Alt-k>", "NC_alt_search k");
assign_to_key ("<Alt-l>", "NC_alt_search l");
assign_to_key ("<Alt-m>", "NC_alt_search m");
assign_to_key ("<Alt-n>", "NC_alt_search n");
assign_to_key ("<Alt-o>", "NC_alt_search o");
assign_to_key ("<Alt-p>", "NC_alt_search p");
assign_to_key ("<Alt-q>", "NC_alt_search q");
assign_to_key ("<Alt-r>", "NC_alt_search r");
assign_to_key ("<Alt-s>", "NC_alt_search s");
assign_to_key ("<Alt-t>", "NC_alt_search t");
assign_to_key ("<Alt-u>", "NC_alt_search u");
assign_to_key ("<Alt-v>", "NC_alt_search v");
assign_to_key ("<Alt-w>", "NC_alt_search w");
assign_to_key ("<Alt-x>", "NC_alt_search x");
assign_to_key ("<Alt-y>", "NC_alt_search y");
assign_to_key ("<Alt-z>", "NC_alt_search z");
assign_to_key ("<Alt-_>", "NC_alt_search _");
assign_to_key ("<Alt-0>", "NC_alt_search 0");
assign_to_key ("<Alt-1>", "NC_alt_search 1");
assign_to_key ("<Alt-2>", "NC_alt_search 2");
assign_to_key ("<Alt-3>", "NC_alt_search 3");
assign_to_key ("<Alt-4>", "NC_alt_search 4");
assign_to_key ("<Alt-5>", "NC_alt_search 5");
assign_to_key ("<Alt-6>", "NC_alt_search 6");
assign_to_key ("<Alt-7>", "NC_alt_search 7");
assign_to_key ("<Alt-8>", "NC_alt_search 8");
assign_to_key ("<Alt-9>", "NC_alt_search 9");
drop_anchor (LINE);
message ("%s", current_dir);
refresh ();
process ();
keyboard_pop ();
delete_window ();
if (new_file != "")
{
if (new_file != "Load Multiple Files")
{
message ("Loading \"%s\" for editing...", new_file);
edit_file (new_file);
old_buffer = inq_buffer ();
}
else
{
top_of_buffer ();
while (search_fwd ("<\\c■"))
{
this_line = read ();
down ();
new_file = trim (substr (this_line, 3, 8));
new_file += "." + trim (substr (this_line, 12, 3));
message ("Loading \"%s\" for editing...", new_file);
edit_file (new_file);
old_buffer = inq_buffer ();
set_buffer (dir_buffer);
}
}
}
set_buffer (old_buffer);
delete_buffer (dir_buffer);
display_file_name ();
}
no_beep (...)
{
return;
}
end_NC_alt (...)
{
get_parm (0, alt_search);
exit ();
}
NC_alt_search (...)
{
extern _do_beep;
int alt_line;
string alt_char;
keyboard_push ();
assign_to_key ("<Enter>", "end_NC_alt <Enter>");
assign_to_key ("<Home>", "end_NC_alt <Home>");
assign_to_key ("<End>", "end_NC_alt <End>");
assign_to_key ("<Up>", "end_NC_alt <Up>");
assign_to_key ("<Down>", "end_NC_alt <Down>");
assign_to_key ("<PgUp>", "end_NC_alt <PgUp>");
assign_to_key ("<PgDn>", "end_NC_alt <PgDn>");
assign_to_key ("<Ins>", "end_NC_alt <Ins>");
assign_to_key ("<Ctrl-PgUp>", "end_NC_alt <Ctrl-PgUp>");
assign_to_key ("<F1>", "end_NC_alt <F1>");
assign_to_key ("<F2>", "end_NC_alt <F2>");
assign_to_key ("<F4>", "end_NC_alt <F4>");
assign_to_key ("<F7>", "end_NC_alt <F7>");
assign_to_key ("<F8>", "end_NC_alt <F8>");